(function(vc){
    vc.extends({
        propTypes: {
           emitChooseAccountBank:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseAccountBankInfo:{
                accountBanks:[],
                _currentAccountBankName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseAccountBank','openChooseAccountBankModel',function(_param){
                $('#chooseAccountBankModel').modal('show');
                $that._refreshChooseAccountBankInfo();
                $that._loadAllAccountBankInfo(1,10,'');
            });
        },
        methods:{
            _loadAllAccountBankInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('accountBank.listAccountBanks',
                             param,
                             function(json){
                                var _accountBankInfo = JSON.parse(json);
                                $that.chooseAccountBankInfo.accountBanks = _accountBankInfo.accountBanks;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseAccountBank:function(_accountBank){
                if(_accountBank.hasOwnProperty('name')){
                     _accountBank.accountBankName = _accountBank.name;
                }
                vc.emit($props.emitChooseAccountBank,'chooseAccountBank',_accountBank);
                vc.emit($props.emitLoadData,'listAccountBankData',{
                    accountBankId:_accountBank.accountBankId
                });
                $('#chooseAccountBankModel').modal('hide');
            },
            queryAccountBanks:function(){
                $that._loadAllAccountBankInfo(1,10,$that.chooseAccountBankInfo._currentAccountBankName);
            },
            _refreshChooseAccountBankInfo:function(){
                $that.chooseAccountBankInfo._currentAccountBankName = "";
            }
        }

    });
})(window.vc);
